package sdk.webview.fmc.com.fmcsdk.check.adapter;

import android.annotation.SuppressLint;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import sdk.webview.fmc.com.fmcsdk.R;
import sdk.webview.fmc.com.fmcsdk.check.bean.WorkHistoryBean;
import sdk.webview.fmc.com.fmcsdk.imagepicker.utils.Utils;
import sdk.webview.fmc.com.fmcsdk.util.StringUtils;

public class OperationHistoryAdapter extends BaseQuickAdapter<WorkHistoryBean.RecordsDTO, BaseViewHolder> {



    public OperationHistoryAdapter(int layoutResId) {
        super(layoutResId);
    }

    @SuppressLint("SetTextI18n")
    @Override
    protected void convert(BaseViewHolder holder, WorkHistoryBean.RecordsDTO item) {

        if ((getData().size() - 1) == holder.getAdapterPosition()) {

            holder.getView(R.id.iv_line).setVisibility(View.GONE);
            holder.getView(R.id.iv_line_last).setVisibility(View.VISIBLE);
        } else {
            holder.getView(R.id.iv_line).setVisibility(View.VISIBLE);
            holder.getView(R.id.iv_line_last).setVisibility(View.GONE);
        }
        holder.setText(R.id.tv_time,Utils.getTimeM_DHMS(item.getOperateDate()));
        holder.setText(R.id.tv_status,item.getOperateTypeDesc());
        holder.setText(R.id.tv_result, StringUtils.isEmpty(item.getOperateRemark()) ? "--": item.getOperateRemark());
        holder.setText(R.id.tv_name,item.getWorkerName());
        TextView tv_phone = holder.getView(R.id.tv_phone);
        if (!StringUtils.isEmpty(item.getWorkerPhone())){
            tv_phone.setVisibility(View.VISIBLE);
            tv_phone.setText("Tel:"+item.getWorkerPhone());
        }else {
            tv_phone.setVisibility(View.GONE);
        }

        holder.setGone(R.id.tv_look_detail, (TextUtils.equals(item.getOperateType(),"SUBCHECK") || (TextUtils.equals(item.getOperateType(),"SUBAPPR")) && !StringUtils.isEmpty(item.getWfEntityId())));

    }


}
